// pages/feedbackVerif/feedbackVerif.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    scrollTop: 0,
    date: '',
    show: false,
    noData:false,
    path_list: [], // 路线选择
    index: 0,
    list: [],
    line_id: '',
    line: '',
    post_time_start: '',
    post_time_end: '',
    statusList: ['待揽件','已揽件','已发车','已到站','已收货'],
    page_start: 1,
    page_size: 10,
    payment_method: [],  // 付款方式
    pullPerson:[], // 揽件人
    pickerConfig: {                     // 时间筛选
      endDate: true,
      dateLimit: false,
      initStartTime: "2019-01-01",
      initEndTime: "2019-12-01",
      limitStartTime: "2000-01-01",
      limitEndTime: "2100-12-31"
    },
    company_type:0,                    //企业类型；0：物流、1：快递
    suspicious_type_list: [
      {suspicious_type: 'yes', suspicious_name: '已反馈'},
      {suspicious_type: 'no', suspicious_name: '未反馈' },
    ],
    employee_name: '',
    is_feedback:'',
    dubiousName: ''
  },
 // 路线选择
 bindPickerChange(e) {
   
  let {
    value
  } = e.detail || {};
  console.log("路线", e, this.data.path_list[value])
  let line = this.data.path_list[value]
  this.setData({
    index: Number(value) || 0,
    line: line.tansline_name,
    line_id: line.tansline_id
  })
},
onDisplay() {
  this.setData({
    show: true
  });
},
onClose() {
  this.setData({
    show: false
  });
},
formatDate(date) {
  date = [new Date(date.startTime), new Date(date.endTime)];
  return `${date[0].getFullYear()}/${date[0].getMonth() + 1}/${date[0].getDate()}-${date[1].getFullYear()}/${date[1].getMonth() + 1}/${date[1].getDate()}`;
},
onConfirm(event) {
  this.setData({
    show: false,
    date: this.formatDate(event.detail),
    post_time_start: parseInt(new Date(event.detail.startTime).getTime()/1000),
    post_time_end: parseInt(new Date(event.detail.endTime).getTime()/1000)
  });
},
onChange(e) {
  this.setData({
    employee_name: e.detail.value
  })
},
onNumChange(e) {
  this.setData({
    logistics_id: e.detail.value
  })
},
bindSuspiciousChange(e){
  let {
    value
  } = e.detail || {};
  let is_feedback = this.data.suspicious_type_list[value].suspicious_type,
  dubiousName = this.data.suspicious_type_list[value].suspicious_name
  this.setData({
    is_feedback: is_feedback,
    dubiousName: dubiousName
  })
},
// 筛选可疑订单
filterData(){
  this.setData({
    list: [],
    page_start: 1
  })


  this.getData();
},

lower: function () {
  var that = this;
  if (that.stopLoadMoreTiem) {
    return;
  }
  console.log("测试")
  this.setData({
    page_start: this.data.page_start + 1 //上拉到底时将page+1后再调取列表接口
  });
   that.getData();
},
getDataall() {
  let pagination = {
    "page_start": this.data.page_start,
    "page_size": 10
  }
  wx.$api.listSuspiciousLogistics(pagination).then(res => {
    if (res.data.code == 200) {
      const rowt = res.data.data.list
      if (rowt == null || rowt.length === 0) {
        this.setData({
          noData: true,
        })
        return;
      }
      if (this.data.page_start === 1) {
        this.setData({
          list: res.data.data.list
        });
      } else {
        this.setData({
          list: this.data.list.concat(rowt)
        });
      }
    } else {
      wx.$Toast(res.data.msg || "服务繁忙")
    }
  })
},
// 获取可疑托运单
getData(){
  let data = {
    post_time_start: this.data.post_time_start,
    post_time_end: this.data.post_time_end,
    employee_name: this.data.employee_name,
    logistics_id: this.data.logistics_id,
    is_feedback: this.data.is_feedback,
    dubious:"1",
    pagination: {
      page_start: this.data.page_start,
      page_size: 10
    }
  }
  wx.$api.listLogistics(data).then(res=>{
    if(res.data.code == 200){
      const rowt = res.data.data.list
      if (rowt == null || rowt.length === 0) {
        this.setData({
          noData: true,
        })
      }
      if (this.data.page_start === 1) {
        this.setData({
          list: res.data.data.list
        });
      } else {
        this.setData({
          list: this.data.list.concat(rowt)
        });
      }
    }else{
      wx.$Toast(res.data.msg || "服务繁忙")
    }
  })
},

// 跳转详情
toDetail (e){
  wx.navigateTo({
    url: '/pages/feedbackDetail/feedbackDetail?id='+e.currentTarget.dataset.id,
  })
},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      path_list: wx.getStorageSync('lineList'),
      company_type: wx.getStorageSync('user_infos').company_type
    })

    this.getData()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})